package abstractfactory

import (
	"fmt"
	"time"
)

// 阿里云计算资源
type AliyunCompute struct {
	instanceID   string
	instanceType string
}

func (r *AliyunCompute) Start() string {
	r.instanceID = fmt.Sprintf("i-aliyun-%x", time.Now().Unix())
	return r.instanceID
}

func (r *AliyunCompute) Stop() error {
	fmt.Printf("aliyun compute stop %s\n", r.instanceID)
	return nil
}

func (r *AliyunCompute) GetInstanceType() string {
	return "aliyun::" + r.instanceType
}

// 阿里存储资源
type AliyunStorage struct {
	bucketName string
}

func (r *AliyunStorage) Upload(file string) error {
	fmt.Printf("aliyun storage upload %s to %s\n", file, r.bucketName)
	return nil
}

func (r *AliyunStorage) Download(file string) error {
	fmt.Printf("aliyun storage download %s from %s\n", file, r.bucketName)
	return nil
}

func (r *AliyunStorage) GetBucketName() string {
	return "aliyun::" + r.bucketName
}

// 阿里支网络资源
type AliyunNetwork struct {
	loadBalancerName string
}

func (r *AliyunNetwork) CreateLoadBalancer() string {
	r.loadBalancerName = fmt.Sprintf("lb-aliyun-%x", time.Now().Unix())
	return r.loadBalancerName
}

func (r *AliyunNetwork) GetLoadBalancerName() string {
	return "aliyun::" + r.loadBalancerName
}
